/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package metamodel.impl;

import metamodel.MetamodelPackage;
import metamodel.Tile;
import metamodel.TileConnector;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Tile</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link metamodel.impl.TileImpl#getIdentifier <em>Identifier</em>}</li>
 *   <li>{@link metamodel.impl.TileImpl#getDescription <em>Description</em>}</li>
 *   <li>{@link metamodel.impl.TileImpl#getConprev <em>Conprev</em>}</li>
 *   <li>{@link metamodel.impl.TileImpl#getConnext <em>Connext</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TileImpl extends EObjectImpl implements Tile {
	/**
	 * The default value of the '{@link #getIdentifier() <em>Identifier</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIdentifier()
	 * @generated
	 * @ordered
	 */
	protected static final String IDENTIFIER_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getIdentifier() <em>Identifier</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIdentifier()
	 * @generated
	 * @ordered
	 */
	protected String identifier = IDENTIFIER_EDEFAULT;

	/**
	 * The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescription()
	 * @generated
	 * @ordered
	 */
	protected static final String DESCRIPTION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescription()
	 * @generated
	 * @ordered
	 */
	protected String description = DESCRIPTION_EDEFAULT;

	/**
	 * The cached value of the '{@link #getConprev() <em>Conprev</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConprev()
	 * @generated
	 * @ordered
	 */
	protected TileConnector conprev;

	/**
	 * The cached value of the '{@link #getConnext() <em>Connext</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConnext()
	 * @generated
	 * @ordered
	 */
	protected TileConnector connext;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TileImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return MetamodelPackage.Literals.TILE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getIdentifier() {
		return identifier;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIdentifier(String newIdentifier) {
		String oldIdentifier = identifier;
		identifier = newIdentifier;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MetamodelPackage.TILE__IDENTIFIER, oldIdentifier, identifier));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDescription(String newDescription) {
		String oldDescription = description;
		description = newDescription;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MetamodelPackage.TILE__DESCRIPTION, oldDescription, description));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TileConnector getConprev() {
		if (conprev != null && conprev.eIsProxy()) {
			InternalEObject oldConprev = (InternalEObject)conprev;
			conprev = (TileConnector)eResolveProxy(oldConprev);
			if (conprev != oldConprev) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, MetamodelPackage.TILE__CONPREV, oldConprev, conprev));
			}
		}
		return conprev;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TileConnector basicGetConprev() {
		return conprev;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetConprev(TileConnector newConprev, NotificationChain msgs) {
		TileConnector oldConprev = conprev;
		conprev = newConprev;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MetamodelPackage.TILE__CONPREV, oldConprev, newConprev);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setConprev(TileConnector newConprev) {
		if (newConprev != conprev) {
			NotificationChain msgs = null;
			if (conprev != null)
				msgs = ((InternalEObject)conprev).eInverseRemove(this, MetamodelPackage.TILE_CONNECTOR__NEXT, TileConnector.class, msgs);
			if (newConprev != null)
				msgs = ((InternalEObject)newConprev).eInverseAdd(this, MetamodelPackage.TILE_CONNECTOR__NEXT, TileConnector.class, msgs);
			msgs = basicSetConprev(newConprev, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MetamodelPackage.TILE__CONPREV, newConprev, newConprev));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TileConnector getConnext() {
		if (connext != null && connext.eIsProxy()) {
			InternalEObject oldConnext = (InternalEObject)connext;
			connext = (TileConnector)eResolveProxy(oldConnext);
			if (connext != oldConnext) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, MetamodelPackage.TILE__CONNEXT, oldConnext, connext));
			}
		}
		return connext;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TileConnector basicGetConnext() {
		return connext;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetConnext(TileConnector newConnext, NotificationChain msgs) {
		TileConnector oldConnext = connext;
		connext = newConnext;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MetamodelPackage.TILE__CONNEXT, oldConnext, newConnext);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setConnext(TileConnector newConnext) {
		if (newConnext != connext) {
			NotificationChain msgs = null;
			if (connext != null)
				msgs = ((InternalEObject)connext).eInverseRemove(this, MetamodelPackage.TILE_CONNECTOR__PREV, TileConnector.class, msgs);
			if (newConnext != null)
				msgs = ((InternalEObject)newConnext).eInverseAdd(this, MetamodelPackage.TILE_CONNECTOR__PREV, TileConnector.class, msgs);
			msgs = basicSetConnext(newConnext, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MetamodelPackage.TILE__CONNEXT, newConnext, newConnext));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MetamodelPackage.TILE__CONPREV:
				if (conprev != null)
					msgs = ((InternalEObject)conprev).eInverseRemove(this, MetamodelPackage.TILE_CONNECTOR__NEXT, TileConnector.class, msgs);
				return basicSetConprev((TileConnector)otherEnd, msgs);
			case MetamodelPackage.TILE__CONNEXT:
				if (connext != null)
					msgs = ((InternalEObject)connext).eInverseRemove(this, MetamodelPackage.TILE_CONNECTOR__PREV, TileConnector.class, msgs);
				return basicSetConnext((TileConnector)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MetamodelPackage.TILE__CONPREV:
				return basicSetConprev(null, msgs);
			case MetamodelPackage.TILE__CONNEXT:
				return basicSetConnext(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case MetamodelPackage.TILE__IDENTIFIER:
				return getIdentifier();
			case MetamodelPackage.TILE__DESCRIPTION:
				return getDescription();
			case MetamodelPackage.TILE__CONPREV:
				if (resolve) return getConprev();
				return basicGetConprev();
			case MetamodelPackage.TILE__CONNEXT:
				if (resolve) return getConnext();
				return basicGetConnext();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case MetamodelPackage.TILE__IDENTIFIER:
				setIdentifier((String)newValue);
				return;
			case MetamodelPackage.TILE__DESCRIPTION:
				setDescription((String)newValue);
				return;
			case MetamodelPackage.TILE__CONPREV:
				setConprev((TileConnector)newValue);
				return;
			case MetamodelPackage.TILE__CONNEXT:
				setConnext((TileConnector)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case MetamodelPackage.TILE__IDENTIFIER:
				setIdentifier(IDENTIFIER_EDEFAULT);
				return;
			case MetamodelPackage.TILE__DESCRIPTION:
				setDescription(DESCRIPTION_EDEFAULT);
				return;
			case MetamodelPackage.TILE__CONPREV:
				setConprev((TileConnector)null);
				return;
			case MetamodelPackage.TILE__CONNEXT:
				setConnext((TileConnector)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case MetamodelPackage.TILE__IDENTIFIER:
				return IDENTIFIER_EDEFAULT == null ? identifier != null : !IDENTIFIER_EDEFAULT.equals(identifier);
			case MetamodelPackage.TILE__DESCRIPTION:
				return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
			case MetamodelPackage.TILE__CONPREV:
				return conprev != null;
			case MetamodelPackage.TILE__CONNEXT:
				return connext != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (identifier: ");
		result.append(identifier);
		result.append(", description: ");
		result.append(description);
		result.append(')');
		return result.toString();
	}

} //TileImpl
